<template>
<ul class="tabs-box">
  <li v-for="(item,i) in data" :key="i" :class="i == index?'active':''" @click="tabClick(i)">
    <a>{{item.title}}</a>
  </li>
</ul>
</template>

<script>
export default {
  name: "CustomTabs",
  props: {
    data:{
      type: Array,
      required: true
    },
    index: {
      type: Number,
      default: 0
    },
    width: {
      type: String,
      default: '100px'
    },
    height: {
      type: String,
      default: '30px'
    },
    gap:{
      type: String,
      default: '10px'
    }
  },
  data() {
    return {
      activeIndex: this.index
    }
  },
  methods: {
    tabClick(index) {
      this.$emit('update:index', index)
    }
  }
}
</script>

<style scoped>
.tabs-box{
  display: flex;
  flex-direction: row;
  gap: v-bind(gap);
  margin: 0;
  padding: 0;
}
.tabs-box li{
  list-style: none;
  background-image: url("@/assets/images/tab.png");
  background-size: 100% 100%;
  height: v-bind(height);
}
.tabs-box li.active{
  background-image: url("@/assets/images/tab_active.png");
  height: calc(v-bind(height) + 13px);
}
.tabs-box li a{
  display: block;
  text-decoration: none;
  width: v-bind(width);
  height: v-bind(height);
  line-height: v-bind(height);
  text-align: center;
  color: #fff;
  letter-spacing: 2px;
  font-size: 14px;
  font-weight: 500;
}
.tabs-box li.active a{
  color: #000936;
}
</style>
